<template>
	<view class="cu-modal " :class="model?'show':''" >
		<view class="cu-dialog">
			<view class="cu-bar bg-white justify-end">
				<view class="content">登录提示</view>
				<view class="action" @tap="hideModal">
					<text class="cuIcon-close text-red"></text>
				</view>
			</view>
			<view class="padding-xl">
				<!-- 是否允许获取您的个人信息吗？ -->
				为了更好地提供服务，将会获取您的头像，昵称，性别，地区等基本信息
			</view>
			<view class="cu-bar bg-white btnList">
				<button class="cu-btn no" @tap="hideModal">拒绝</button>
				<button class="cu-btn yes" @getuserinfo="login" lang="zh_CN"  open-type="getUserInfo">允许</button>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				CustomBar: this.CustomBar,
				modalName: null,
				model:true
			};
		},
        name: 'login',
        created(){
			this.model=true
			
			console.log(111);

        },
		computed: {
            
			
		},
		props: {
			
		},
		methods: {
			async login(e){
                let openid= await uni.$get_openId()
				let user_info={
					...e.detail.userInfo,
					openid
				}
				const res=await uni.$request({
					...user_info
				},"api/user/login")
				if (res.code==200) {
					uni.setStorageSync("user_info", user_info)
					uni.setStorageSync("token", res.data.token)
					this.$parent.login=true
					this.hideModal()
				}
            },
            showModal(e) {
				this.model = true
			},
			hideModal(e) {
				this.model = false
				this.$parent.login=true
			},
		}
	}
</script>

<style lang="scss">
    .btnList{
		justify-content: space-evenly;
		.no{
			color: $main_col;
			border-color: $main_col;
		}
		.yes{
			color: #fff;
			background:$main_col ;
		}
	}
</style>